﻿using System;
using NHibernate.Criterion;

namespace Products.DataAcccess
{
    public class ProductDao : Ornament.NHibernates.DaoBase<Guid, Product>
    {
        protected override Order DefaultOrder
        {
            get { return Order.Asc("Name"); }
        }

        public Product Get(string name)
        {
            return CreateDetachedCriteria().Add(Restrictions.Eq("Name", name))
                .GetExecutableCriteria(CurrentSession).UniqueResult<Product>();
        }
    }
}
